package com.zzw.mvvm.repository.local;

import android.content.Context;

import com.zzw.mvvm.beans.DemoEntity;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

@Database(entities = {DemoEntity.class}, version = 1,exportSchema = false)
public abstract class AppDataBase extends RoomDatabase {
    private static AppDataBase INSTANCE;
    private static final Object sLock = new Object();
    private static final String DB_NAME = "user.db";

    public abstract DemoDao demoDao();

    public static AppDataBase getInstance(Context context) {
        synchronized (sLock) {
            if (INSTANCE == null) {
                INSTANCE =
                        Room.databaseBuilder(context.getApplicationContext(), AppDataBase.class, DB_NAME)
                                .build();
            }
            return INSTANCE;
        }
    }
}
